﻿<Window xmlns:local="clr-namespace:AutoSizeRegionsWithSplitter"  x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="373" Width="584">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="100" />
      <ColumnDefinition Width="*" />
      <ColumnDefinition x:Name="clmForm" Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="100" />
    </Grid.RowDefinitions>
    <Button Content="left side" Margin="7,7,12,7" Grid.RowSpan="2" />
    <GridSplitter Grid.RowSpan="2" HorizontalAlignment="Right" Width="5" Background="Red" VerticalAlignment="Stretch" />
    <GridSplitter Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Background="Green" Height="5" />
    <GridSplitter Visibility="{Binding ElementName=bdrForm, Path=Visibility}" Grid.Column="1"  HorizontalAlignment="Right" Width="5" Background="Red" VerticalAlignment="Stretch" />
    
    <Border Grid.Column="1" Margin="7,7,12,12" BorderBrush="Red" Background="FloralWhite" CornerRadius="10" BorderThickness="2"/>

    <ListView Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" ItemsSource="{x:Static local:Data.People}">
      <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
          <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        </Style>
      </ListView.ItemContainerStyle>
      <ListView.View>
        <GridView>
          <GridViewColumn Header="First Name" DisplayMemberBinding="{Binding Path=FirstName}" Width="100" />
          <GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding Path=LastName}" Width="100" />
          <GridViewColumn>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <Button Click="btnDetails_Click" Content="Details" FontSize="9" Width="35" Height="18" />
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
        </GridView>
      </ListView.View>
    </ListView>

    <Border x:Name="bdrForm" Visibility="Collapsed" Grid.Column="2" BorderBrush="LightGray" BorderThickness="1" CornerRadius="10" Padding="10">
      <Grid VerticalAlignment="Top">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="75" />
          <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Text="Person" />
        <Label Grid.Column="0" Grid.Row="1" Content="First Name" />
        <Label Grid.Column="0" Grid.Row="2" Content="Last Name" />
        <Label Grid.Column="0" Grid.Row="3" Content="Profession" />
        <Label Grid.Column="0" Grid.Row="4" Content="Sex" />


        <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=FirstName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" MaxLength="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
        <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=LastName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" MaxLength="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
        <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=Profession, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" MaxLength="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
        <TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=Sex, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
      
        <Button Content="Hide" Grid.Row="5"  Grid.Column="1" Click="btnHide_Click"/>
        
      </Grid>
    </Border>


  </Grid>
</Window>
